import { get, post } from '@/utils/request';

export interface LoginParams {
    username: string;
    password: string;
}

export interface UserInfo {
    id: number;
    username: string;
    name: string;
    avatar: string;
    roles: string[];
}

/**
 * 用户登录
 */
export const login = (data: LoginParams) => {
    return post<{ token: string }>('/user/login', data);
};

/**
 * 获取用户信息
 */
export const getUserInfo = () => {
    return get<UserInfo>('/user/info');
};

/**
 * 用户退出
 */
export const logout = () => {
    return post('/user/logout');
};